import 'package:flutter/cupertino.dart';
import 'package:go_router/go_router.dart';
import 'package:myapp/page/about/about.dart';
import 'package:myapp/page/messageTransfer/index.dart';
import 'package:myapp/page/position/position.dart';
import 'package:myapp/page/bluetooth/index.dart';
import 'package:myapp/page/address/address.dart';

CustomTransitionPage customPage(context, state, Widget custom) {
  return CustomTransitionPage(
    key: state.pageKey,
    child: custom,
    transitionsBuilder: (context, animation, secondaryAnimation, child) {
      return FadeTransition(
        opacity: CurveTween(curve: Curves.easeInOutCirc).animate(animation),
        child: child,
      );
    },
  );
}

// Address

final GoRouter router = GoRouter(
  routes: [
    // 用户页面路由（包含子路由）
    GoRoute(
      path: '/',
      builder: (context, state) => const Address(),
    ),
    GoRoute(
      path: '/about',
      builder: (context, state) => const About(),
      routes: [
        // 子路由1: 用户详情
        GoRoute(
          path: 'MessageTransfer',
          builder: (context, state) => const MessageTransfer(),
        ),
      ],
    ),
    GoRoute(
      path: '/bluetooth',
      builder: (context, state) => const Bluetooth(),
    ),
    GoRoute(
      path: '/position',
      builder: (context, state) => const Position(),
    ),
  ],
);
